
import { ItemModel } from 'js/model/itemModel'
import { gameConfigHandle } from 'js/config/gameConfig'

class ItemHandle {
    create({ tID, stack, pos, hp, isNew, lvl }: any, rand): ItemModel {
        let it = gameConfigHandle.configByID[tID]
        if (!it) {
            return null
        }
        stack = stack || 1

        let item = new ItemModel({
            tID: tID || 0,
            stack: stack,
            pos: pos || 0,
            hp: hp || it.maxHp || 0,
            new: isNew || false,
            lvl: lvl || 0
        })
        return item
    }
}

let itemHandle = new ItemHandle()
export default itemHandle

